Platform Explorer / Nuxeo Platform LTS 2019 10.10

Contribution org.nuxeo.vision.core.chains--operation

This contribution is part of XML component org.nuxeo.vision.core.chains inside nuxeo-vision-core-1.3.4.jar /OSGI-INF/default-chain-contrib.xml

Extension Point

Extension point operation of component AutomationScriptingComponent.

Registration Order

1
The registration order represents the order in which this contribution was registered on its target extention point. This will impact the override/merge behaviour when it is implemented on the target service, and is useful for proper customization of existing contributions.
You can influence this order by adding "require" tags in the containing component declaration, to make sure it is resolved after another component (see "Resolution Order" on components).

Contributed Items

  • <scriptedOperation id="javascript.PictureVisionDefaultMapper">
          <inputType>Document</inputType>
          <outputType>Document</outputType>
          <category>javascript</category>
          <description/>
          <script><![CDATA[function run(input, params) {
    
                  var blob = Picture.GetView(input, {'viewName': 'Medium'});
    
                  blob = VisionOp(blob, {
                    'features': ['LABEL_DETECTION'],
                    'maxResults': 5,
                    'outputVariable': 'annotations'
                  });
    
                  var annotations = ctx.annotations;
    
                  if (annotations===undefined || annotations.length===0) return;
    
                  var textAndLabels = annotations[0];
    
                  // build tag list
                  var labels = textAndLabels.getClassificationLabels();
    
                  if (labels !== undefined && labels !== null && labels.length>0) {
                      var tags = [];
                      for(var i=0;i<labels.length;i++) {
                        var label = labels[i];
                        var tag = label.getText();
                        if (tag ===undefined || tag ===null) continue;
                        tags.push(tag.replace(/[^A-Z0-9]+/ig,'+'));
                      }
    
                      input = Services.TagDocument(input, {'tags': tags });
                  }
    
                  return input;
    
            }]]></script>
        </scriptedOperation>
  • <scriptedOperation id="javascript.VideoVisionDefaultMapper">
          <inputType>Document</inputType>
          <outputType>Document</outputType>
          <category>javascript</category>
          <description/>
          <script><![CDATA[function run(input, params) {
                  var storyboard = input['vid:storyboard'];
                  var blobs = [];
                  var index;
                  var tags = [];
    
                  for (index=0;index<storyboard.length;index++) {
    
                    var blob = storyboard[index].content;
    
                    VisionOp(blob, {
                      'features': ['LABEL_DETECTION'],
                      'maxResults': 5,
                      'outputVariable': 'annotations'
                    });
    
                    var annotations = ctx.annotations;
    
                    if (annotations===undefined || annotations.length===0) return;
    
                    // build tag list
                    var textAndLabels = annotations[0];
                    var labels = textAndLabels.getClassificationLabels();
    
                    if (labels === undefined || labels === null || labels===0) continue;
    
                    for(var j=0;j<labels.length;j++) {
                        var label = labels[j];
                        var tag = label.getText();
                        if (tag ===undefined || tag ===null) continue;
                        tags.push(tag.replace(/[^A-Z0-9]+/ig,'+'));
                        tags.push(label.getText().replace(/\s/g,'+'));
                    }
                  }
    
                  input = Services.TagDocument(input, {'tags': tags });
    
                  return input;
    
                }]]></script>
        </scriptedOperation>

XML Source

<extension point="operation" target="org.nuxeo.automation.scripting.internals.AutomationScriptingComponent">
    <scriptedOperation id="javascript.PictureVisionDefaultMapper">
      <inputType>Document</inputType>
      <outputType>Document</outputType>
      <category>javascript</category>
      <description/>
      <script><![CDATA[function run(input, params) {

              var blob = Picture.GetView(input, {'viewName': 'Medium'});

              blob = VisionOp(blob, {
                'features': ['LABEL_DETECTION'],
                'maxResults': 5,
                'outputVariable': 'annotations'
              });

              var annotations = ctx.annotations;

              if (annotations===undefined || annotations.length===0) return;

              var textAndLabels = annotations[0];

              // build tag list
              var labels = textAndLabels.getClassificationLabels();

              if (labels !== undefined && labels !== null && labels.length>0) {
                  var tags = [];
                  for(var i=0;i<labels.length;i++) {
                    var label = labels[i];
                    var tag = label.getText();
                    if (tag ===undefined || tag ===null) continue;
                    tags.push(tag.replace(/[^A-Z0-9]+/ig,'+'));
                  }

                  input = Services.TagDocument(input, {'tags': tags });
              }

              return input;

        }]]></script>
    </scriptedOperation>

    <scriptedOperation id="javascript.VideoVisionDefaultMapper">
      <inputType>Document</inputType>
      <outputType>Document</outputType>
      <category>javascript</category>
      <description/>
      <script><![CDATA[function run(input, params) {
              var storyboard = input['vid:storyboard'];
              var blobs = [];
              var index;
              var tags = [];

              for (index=0;index<storyboard.length;index++) {

                var blob = storyboard[index].content;

                VisionOp(blob, {
                  'features': ['LABEL_DETECTION'],
                  'maxResults': 5,
                  'outputVariable': 'annotations'
                });

                var annotations = ctx.annotations;

                if (annotations===undefined || annotations.length===0) return;

                // build tag list
                var textAndLabels = annotations[0];
                var labels = textAndLabels.getClassificationLabels();

                if (labels === undefined || labels === null || labels===0) continue;

                for(var j=0;j<labels.length;j++) {
                    var label = labels[j];
                    var tag = label.getText();
                    if (tag ===undefined || tag ===null) continue;
                    tags.push(tag.replace(/[^A-Z0-9]+/ig,'+'));
                    tags.push(label.getText().replace(/\s/g,'+'));
                }
              }

              input = Services.TagDocument(input, {'tags': tags });

              return input;

            }]]></script>
    </scriptedOperation>

  </extension>